/**
 * Created by thomas on 2018/2/18.
 */

const Goto = {};
Goto.install = function (Vue, options) {
  Vue.mixin({
    methods:{
      $goto:function (opt) {
        this.$store.dispatch("thom_redirect",
          {
            name:opt,router:this.$router
          });
      },
      $goback:function(){
        this.$router.back();
      },
      //anitype or show: http://www.dcloud.io/docs/api/zh_cn/webview.html#plus.webview.AnimationTypeShow
      $mui_goto:function (obj) {
        console.log("mui_goto");
        console.log(obj);
        if(!!obj.show){
          obj.show = {
            autoShow: true,//页面loaded事件发生后自动显示，默认为true
            aniShow: 'none',//页面显示动画，默认为”slide-in-right“；
          }
        }
        mui.plusReady(function () {
          console.log("当前页面URL：" + plus.webview.currentWebview().getURL());
          mui.openWindow({
            url: obj.url,
            id: obj.id,
            show:obj.show
          });
        })
      },
      $mui_goback:function(opt){
        mui.plusReady(function () {
          mui.currentWebview.close();
          mui.back()
        })
      },
    }
  })
}
module.exports = Goto;
